package priv.yiyuan.example.design.proxy;

/**
 * 部门经理审批处理
 * <p>
 * 责任链模式-具体处理者
 *
 * @author YiYuan
 * @data 2025/9/26
 * @apoNote
 */
public class ManagerApprovalHandler implements OrderApprovalHandler {

    private OrderApprovalHandler nextHandler;

    @Override
    public void setNextHandler(OrderApprovalHandler nextHandler) {
        this.nextHandler = nextHandler;
    }

    @Override
    public void handleRequest(Order order) {
        if (order.getAmount() <= 5000) {
            System.out.println("[经理审批] 订单ID: " + order.getOrderId() + ", 金额: " + order.getAmount() + " 元, 由经理审批通过。");
        }
        else if (nextHandler != null) {
            System.out.println("[经理审批] 订单ID: " + order.getOrderId() + ", 金额过大, 转交财务审批。");
            nextHandler.handleRequest(order);
        }
        else {
            System.out.println("[经理审批] 订单ID: " + order.getOrderId() + ", 金额过大, 无后续处理者, 审批失败。");
        }
    }
}
